| 
| advbot.inc 
| Include file for advbot.mac 
| Version 1.99b-final 
| Date:8/19/2005 
| 

#Event Master "[MQ2] master#*#" 
#Event Debuff "[MQ2] debuff#*#" 
#Event Sit "[MQ2] sit#*#" 
#Event SelfBuff "[MQ2] selfbuff#*#" 
#Event GroupBuff "[MQ2] groupbuff#*#" 
#Event Evts "[MQ2] events#*#" 
#Event Heal "[MQ2] heal#*#" 
#Event Pet "[MQ2] pet#*#" 
#Event Exclude "[MQ2] exclude#*#" 
#Event Include "[MQ2] include#*#" 
#Event Announce "[MQ2] announce#*#" 
#Event Reply "[MQ2] reply#*#" 
#Event Watch "[MQ2] watch#*#" 
#Event Assist "[MQ2] assist#*#" 
#Event Cmd "[MQ2] cmd#*#" 
#Event Face "[MQ2] face#*#" 
#Event Buff "[MQ2] buff#*#" 
#Event Invite "#*#invites you to join a group.#*#" 
#Event Slain "#*#Returning to home point, please wait...#*#" 
#Event DelayOnZone "#*#You have entered#*#" 
#Event Enraged "#*#has become ENRAGED#*#" 


Sub DebuffFunction 
/if (${PauseDebuffs}==0) { 
    /varset PauseDebuffs 1 
    /echo -[ Debuffing Paused. ]- 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm not going to debuff. 
} else { 
    /varset PauseDebuffs 0 
    /echo -[ Debuffing Un-Paused. ]- 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm going to debuff. 
} 
/return 

Sub Event_Debuff(EvtText) 
/varset EvtText ${EvtText.Right[-6]} 
/if (${EvtText.Equal["debuff"]}) { 
    /varset SenderName nobody 
    /call DebuffFunction 
} 
/return 

Sub EvtsFunction 
/if (${PauseEvents}==0) { 
    /varset PauseEvents 1 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm not going to pay attention to hp or mana events. 
    /echo -[ HP/Mana events Paused. ]- 
} else { 
    /varset PauseEvents 0 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm going to pay attention to hp or mana events. 
    /echo -[ HP/Mana events Unpaused. ]- 
} 
/return 

Sub Event_Evts 
/varset SenderName nobody 
/call EvtsFunction 
/return 

Sub HealFunction(HealCmd) 
/if (${Defined[HealCmd]}) { 
    /if (${HealCmd.Equal[pets]}) { 
        /if (${HealPets}==1) { 
            /varset HealPets 0 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'm not going to heal pets anymore. 
            /echo -[ Pet Healing Paused. ]- 
        } else { 
            /varset HealPets 1 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll heal pets. 
            /echo -[ Pet Healing Unpaused. ]- 
        } 
    } 
    /return 
} else { 
    /if (${PauseHeals}==0) { 
        /varset PauseHeals 1 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'm not going to watch your health, so don't die! 
        /echo -[ Healing Paused. ]- 
    } else { 
        /varset PauseHeals 0 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'll watch you for heals. 
        /echo -[ Healing Unpaused. ]- 
    } 
} 
/return 

Sub Event_Heal(EvtText) 
/if (${EvtText.Right[-11].Length}>0) { 
    /varset SenderName nobody 
    /call HealFunction "${EvtText.Right[-11]}" 
} else { 
    /varset SenderName nobody 
    /call HealFunction 
} 
/return 

Sub PetFunction(PetCmd) 
/declare f int local 
/declare Reason string local 
/if (${Defined[PetCmd]}) { 
    /if (${PetCmd.Equal[summon]}) { 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll summon a pet. 
        /echo -[ Summoning a pet. ]- 
        /if ((${Me.Gem[${PetSummonSpell}]})||(${PetSummonSpell.Find["item"]})||(${PetSummonSpell.Find["activate"]})||(${PetSummonMemToSlot}>0)) { 
            /if ((${PetSummonSpell.Find["activate"]})&&(!${Me.AltAbilityReady[${PetSummonSpell.Right[-9]}]})) { 
                /varset Reason Ability Not Ready 
                /goto :ErrorSummon 
            } 
            /if ((!${PetSummonSpell.Find["item"]}>0)&&(!${PetSummonSpell.Find["activate"]}>0)) { 
                /if (${Me.Gem[${PetSummonSpell}]}) { 
                    /for f 1 to 30 
                        /delay 1 
                        /if (${Me.SpellReady["${PetSummonSpell}"]}) { 
                            /goto :ContinueSummon 
                        } 
                    /next f 
                    /if (!${Me.SpellReady["${PetSummonSpell}"]}) { 
                        /varset Reason Spell Not Ready 
                        /goto :ErrorSummon 
                    } 
                } 
            } 
            :ContinueSummon 
            /if (!${Me.Standing}) /stand 
            /if (${PetSummonSpell.Left[4].Equal["item"]}) { 
                /echo -[ Casting Pet Summon : ${PetSummonSpell}. ]- 
                /call Cast "${PetSummonSpell.Right[-5]}" "item" "nocheck" 
            } else /if (${PetSummonSpell.Left[8].Equal["activate"]}) { 
                /echo -[ Casting Pet Summon : ${PetSummonSpell}. ]- 
                /call Cast "${PetSummonSpell.Right[-9]}" "activate" "nocheck" 
            } else { 
                /echo -[ Casting Pet Summon : ${PetSummonSpell}. ]- 
                /call Cast "${PetSummonSpell}" "gem${PetSummonMemToSlot}" "nocheck" 
            } 
            /if (${Macro.Return.Equal["CAST_TOOK2LONG"]}) { 
                /echo -(( Cast took too long, aborting. ))- 
                /varset Reason Cast Took Too Long 
                /goto :ErrorSummon 
            } 
        } else { 
            /varset Reason Unknown Error 
            /goto :ErrorSummon 
        } 
    } else { 
        /pet ${PetCmd} 
    } 
    /return 
    :ErrorSummon 
    /delay 15 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Couldn't summon pet because ${Reason}. 
    /echo -(( Couldn't Summon Pet - Reason:${Reason}. ))- 
} else { 
    /if (${PausePet}==0) { 
        /varset PausePet 1 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm not going to have my pet assist you. 
        /echo -[ Pet Assisting Paused. ]- 
    } else { 
        /varset PausePet 0 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm going to have my pet assist you. 
        /echo -[ Pet Assisting Unpaused. ]- 
    } 
} 
/return 

Sub Event_Pet(EvtText) 
/if (${EvtText.Right[-10].Length}>0) { 
    /varset SenderName nobody 
    /call PetFunction "${EvtText.Right[-10]}" 
} else { 
    /varset SenderName nobody 
    /call PetFunction 
} 
/return 

Sub CmdFunction(CmdStr) 
/if (${Defined[CmdStr]}) { 
    /if (${CmdStr.Length}>0) { 
        /docommand /${CmdStr} 
    } 
} 
/return 

Sub Event_Invite(EvtText) 
/declare TempVar int local 
/varset TempVar 0 
:CheckAuth 
/if (!${MasterList[${TempVar}].Equal["UNDEFINED-ARRAY-ELEMENT"]}) { 
    /if (${MasterList[${TempVar}].Equal["${EvtText.Arg[1]}"]}) { 
        /invite 
        /return 
    } 
    /varset TempVar ${Math.Calc[${TempVar}+1]} 
    /goto :CheckAuth 
} 
/return 


Sub Event_Cmd(EvtText) 
/if (${EvtText.Right[-10].Length}>0) { 
    /varset SenderName nobody 
    /call CmdFunction "${EvtText.Right[-10]}" 
} 
/return 

Sub AssistFunction(TankNm) 
/if (${Defined[TankNm]}) { 
    /varset TankName ${TankNm} 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'm going to assist ${TankName} while we are fighting. 
    /echo -[ Assisting ${TankName} During Combat. ]- 
} else { 
    /if (${PauseAssist}==0) { 
        /varset PauseAssist 1 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'm not going to assist the tank while we are fighting. 
        /echo -[ Assisting Paused. ]- 
    } else { 
        /varset PauseAssist 0 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'll assist the tank while we are fighting. 
        /echo -[ Assisting Unpaused. ]- 
    } 
} 
/return 

Sub Event_Assist(EvtText) 
/if (${EvtText.Arg[3].Length}>0) { 
    /varset SenderName nobody 
    /call AssistFunction "${EvtText.Arg[3]}" 
} else { 
    /varset SenderName nobody 
    /call AssistFunction 
} 
/return 


Sub ReplyFunction 
/if (${Reply}==0) { 
    /varset Reply 1 
/echo ${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'm going to reply. 
    /if (!${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'm going to reply. 
    /echo -[ Replies turned ON. ]- 
} else { 
    /varset Reply 0 
    /if (!${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'm not going to reply. 
    /echo -[ Replies turned OFF. ]- 
} 
/return 

Sub Event_Reply(EvtText) 
/varset SenderName nobody 
/call ReplyFunction 
/return 


Sub AnnounceFunction 
/if (${Announce}==0) { 
    /varset Announce 1 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'm going to tell people what I'm doing. 
    /echo -[ Announcements turned ON. ]- 
} else { 
    /varset Announce 0 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'm not going to bother telling people what I'm doing. 
    /echo -[ Announcements turned OFF. ]- 
} 
/return 

Sub Event_Announce(EvtText) 
/varset SenderName nobody 
/call AnnounceFunction 
/return 

Sub FaceFunction 
/if (${FaceBeforeDebuff}==0) { 
    /varset FaceBeforeDebuff 1 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'm not going to bother looking at mobs when I debuff them. 
    /echo -[ Facing before debuffs turned ON. ]- 
} else { 
    /varset FaceBeforeDebuff 0 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'll look at mobs when I debuff them. 
    /echo -[ Facing before debuffs turned OFF. ]- 
} 
/return 

Sub Event_Face 
/varset SenderName nobody 
/call FaceFunction 
/return 

Sub SelfBuffFunction(CmdText) 
/declare a int local 
/declare b int local 
/declare c int local 
/declare TempIndex int local 
/declare TempIndex2 int local 
/if (${SelfBuffCount}>0) { 
    /if (${CmdText.Equal["selfbuff"]}) { 
        /if (${PauseSelfBuffs}==0) { 
            /varset PauseSelfBuffs 1 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm not going to self buff. 
            /echo -[ Self Buffs Paused. ]- 
        } else { 
            /varset PauseSelfBuffs 0 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm going to self buff. 
            /echo -[ Self Buffs Unpaused. ]- 
        } 
    } else /if (${CmdText.Right[-9].Equal["all"]}) { 
        /for a 1 to ${SelfBuffCount} 
            /varset SelfBuffedList[${a}] 0 
        /next a 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll totally buff myself. 
        /echo -[ Self Buffing with all buffs. ]- 
    } else { 
        /for b 1 to 8 
            /if (${CmdText.Arg[2].Equal["${b}"]}) { 
                /if ((${CmdText.Arg[2]}>0)&&(${CmdText.Arg[2]}<${Math.Calc[${SelfBuffCount}+1]})) { 
                    /varset TempIndex ${CmdText.Arg[2]} 
                    /if (${TempIndex}>0) { 
                        /varset SelfBuffedList[${TempIndex}] 0 
                        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll buff myself with ${SelfBuff[${b}]}. 
                        /echo -[ Self Buffing with ${SelfBuff[${b}]}. ]- 
                    } 
                    /goto :BreakOutRebuff 
                } 
            } 
        /next b 

        :LookUpAlias 
        /varset TempIndex2 0 
        /for c 1 to 8 
            /if (${SelfBuffAliasName[${c}].Equal[${CmdText.Arg[2]}]}) /varset TempIndex2 ${c} 
        /next c 

        /if ((${TempIndex2}>0)&&(${TempIndex2}<${Math.Calc[${SelfBuffCount}+1]})) { 
            /varset TempIndex ${TempIndex2} 
            /if (${TempIndex}>0) { 
                /varset SelfBuffedList[${TempIndex}] 0 
                /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll buff myself with ${SelfBuff[${TempIndex}]}. 
                /echo -[ Self Buffing with ${SelfBuff[${TempIndex}]}. ]- 
            } 

        } 
        :BreakOutRebuff 
    } 
} 
/return 

Sub Event_Slain 
/echo -(( Death detected, waiting 10 seconds and then putting all functions on hold. ))- 
/echo -(( You must issue the appropriate command to restart each function or restart. ))- 
/delay 10s 
/if (${PauseDebuffs}==0) /call DebuffFunction 
/if (${PauseEvents}==0) /call EvtsFunction 
/if (${PauseHeals}==0) /call HealFunction 
/if (${PauseSelfBuffs}==0) /call SelfBuffFunction "selfbuff" 
/if (${PauseGroupBuffs}==0) /call GroupBuffFunction "groupbuff" 
/call Wait4Rez
/return 

Sub Event_SelfBuff(EvtText) 
/varset EvtText ${EvtText.Right[-6]} 
/varset SenderName nobody 
/call SelfBuffFunction "${EvtText}" 
/return 

Sub BuffFunction(CmdText) 
/declare a int local 
/declare b int local 
/declare c int local 
/declare f int local 
/declare Reason string local 
/declare TempIndex int local 
/declare TempIndex2 string local 
/declare PlayerID int local 
/declare BuffPlayerName string local 
/if (!${CmdText.Arg[3].Length}>0) { 
    /varset Reason You didn't give a name 
    /goto :ErrorBuff 
} 
/varset BuffPlayerName ${CmdText.Right[-5]} 
/varset BuffPlayerName ${BuffPlayerName.Mid[${BuffPlayerName.Find[" "]},${BuffPlayerName.Length}]} 
/varset PlayerID ${NearestSpawn[1,pc ${BuffPlayerName}].ID} 
/if (!${PlayerID}>0) /varset PlayerID ${NearestSpawn[1,pet ${BuffPlayerName}].ID} 
/if (!${PlayerID}>0) { 
    /varset Reason I don't see them around 
    /goto :ErrorBuff 
} 
/if (${GroupBuffCount}>0) { 
    /if (${CmdText.Right[-5].Arg[2].Length}>0) { 
        /varset TempIndex2 0 
        /for c 1 to 8 
            /if (${GroupBuffAliasName[${c}].Equal[${CmdText.Arg[2]}]}) /varset TempIndex2 ${c} 
        /next c 
        /if (${TempIndex2.Equal[0]}) /varset TempIndex2 ${CmdText.Arg[2]} 

        /for a 1 to 8 
            /if (${TempIndex2.Equal["${Int[${a}]}"]}) { 
                /if ((${Int[${TempIndex2}]}>0)&&(${Int[${TempIndex2}]}<${Math.Calc[${GroupBuffCount}+1]})) { 
                    /if (${PlayerID}>0 && ${Spawn[${PlayerID}].Distance}<85) { 
                        /varset TempIndex ${TempIndex2} 
                        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll buff ${BuffPlayerName} with ${GroupBuff[${a}]}. 
                        /echo -[ Buffing ${BuffPlayerName} with ${GroupBuff[${a}]}. ]- 
                        /if ((${Me.Gem[${GroupBuff[${a}]}]})||(${GroupBuff[${a}].Find["item"]})||(${GroupBuff[${a}].Find["activate"]})||(${GroupBuffMemToSlot[${a}]}>0)) { 
                            /if ((${GroupBuff[${a}].Find["activate"]})&&(!${Me.AltAbilityReady[${GroupBuff[${a}].Right[-9]}]})) { 
                                /varset Reason Ability Not Ready 
                                /goto :ErrorBuff 
                            } 
                            /if ((!${GroupBuff[${a}].Find["item"]}>0)&&(!${GroupBuff[${a}].Find["activate"]}>0)) { 
                                /if (${Me.Gem[${GroupBuff[${a}]}]}) { 
                                    /for f 1 to 30 
                                        /delay 1 
                                        /if (${Me.SpellReady["${GroupBuff[${a}]}"]}) { 
                                            /goto :ContinueGroupBuff 
                                        } 
                                    /next f 
                                    /if (!${Me.SpellReady["${GroupBuff[${a}]}"]}) { 
                                        /varset Reason Spell Not Ready 
                                        /goto :ErrorBuff 
                                    } 
                               } 
                            } 
                            :ContinueGroupBuff 
                            /if (${Me.ID}!=${PlayerID}) { 
                                /squelch /target id ${PlayerID} 
                            } else { 
                                /squelch /target myself 
                            } 
                            /delay 1s ${Target.ID}==${PlayerID} 
                            /if (!${Target.CleanName.Equal[${BuffPlayerName}]}) { 
                                /varset Reason Can't target ${BuffPlayerName} 
                                /goto :ErrorBuff 
                            } 
                            /if (!${Me.Standing}) /stand 
                            /if (${GroupBuff[${a}].Left[4].Equal["item"]}) { 
                                /echo -[ Casting Buff : ${GroupBuff[${a}]} on ${BuffPlayerName}. ]- 
                                /call Cast "${GroupBuff[${a}].Right[-5]}" "item" "${Dismount}" 
                            } else /if (${GroupBuff[${a}].Left[8].Equal["activate"]}) { 
                                /echo -[ Casting Buff : ${GroupBuff[${a}]} on ${BuffPlayerName}. ]- 
                                /call Cast "${GroupBuff[${a}].Right[-9]}" "activate" "${Dismount}" 
                            } else { 
                                /echo -[ Casting Buff : ${GroupBuff[${a}]} on ${BuffPlayerName}. ]- 
                                /call Cast "${GroupBuff[${a}]}" "gem${GroupBuffMemToSlot[${a}]}" "${Dismount}" 
                            } 
                            /if (${Macro.Return.Equal["CAST_TOOK2LONG"]} || ${Macro.Return.Equal["CAST_LOSTTARGET"]}) { 
                                /echo -(( Cast took too long or lost target, aborting. ))- 
                                /varset Reason Cast Took Too Long or Lost Target 
                                /goto :ErrorBuff 
                            } 
                            /if ((${Macro.Return.Equal["CAST_CANNOTSEE"]})||(${Macro.Return.Equal["CAST_OUTOFRANGE"]})) { 
                                /echo -(( Out of range or cannot be seen, aborting. ))- 
                                /varset Reason Target Out of Range 
                                /goto :ErrorBuff 
                            } 
                        } else { 
                            /varset Reason Unknown Error 
                            /goto :ErrorBuff 
                        } 
                        /goto :BreakOutRebuff1 
                    } else { 
                        /varset Reason Target Not in Zone or too far away 
                        /goto :ErrorBuff 
                    } 
                } 
            } 
        /next a 
        /if (${CmdText.Arg[2].Equal[all]}) { 
                /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, buffing ${BuffPlayerName} with every buff. 
                /echo -[ Buffing Target ${BuffPlayerName} with all group buffs. ]- 
                /for a 1 to ${GroupBuffCount} 
                    /if (${PlayerID}>0 && ${Spawn[${PlayerID}].Distance}<85) { 
                        /varset TempIndex ${CmdText.Arg[2]} 
                        /echo -[ Buffing ${BuffPlayerName} with ${GroupBuff[${a}]}. ]- 
                        /if ((${Me.Gem[${GroupBuff[${a}]}]})||(${GroupBuff[${a}].Find["item"]})||(${GroupBuff[${a}].Find["activate"]})||(${GroupBuffMemToSlot[${a}]}>0)) { 
                            /if ((${GroupBuff[${a}].Find["activate"]})&&(!${Me.AltAbilityReady[${GroupBuff[${a}].Right[-9]}]})) { 
                                /varset Reason Ability Not Ready 
                                /goto :ErrorBuff 
                            } 
                            /if ((!${GroupBuff[${a}].Find["item"]}>0)&&(!${GroupBuff[${a}].Find["activate"]}>0)) { 
                                /if (${Me.Gem[${GroupBuff[${a}]}]}) { 
                                    /for f 1 to 30 
                                        /delay 1 
                                        /if (${Me.SpellReady["${GroupBuff[${a}]}"]}) { 
                                            /goto :ContinueGroupBuff2 
                                        } 
                                    /next f 
                                    /if (!${Me.SpellReady["${GroupBuff[${a}]}"]}) { 
                                        /varset Reason Spell Not Ready 
                                        /goto :ErrorBuff 
                                    } 
                                } 
                            } 
                            :ContinueGroupBuff2 
                            /if (${Me.ID}!=${PlayerID}) { 
                                /squelch /target id ${PlayerID} 
                            } else { 
                                /squelch /target myself 
                            } 
                            /delay 1s ${Target.ID}==${PlayerID} 

                            /if (!${Target.CleanName.Equal[${BuffPlayerName}]}) { 
                                /varset Reason Can't target ${BuffPlayerName} 
                                /goto :ErrorBuff 
                            } 
                            /if (!${Me.Standing}) /stand 
                            /if (${GroupBuff[${a}].Left[4].Equal["item"]}) { 
                                /echo -[ Casting Buff : ${GroupBuff[${a}]} on ${BuffPlayerName}. ]- 
                                /call Cast "${GroupBuff[${a}].Right[-5]}" "item" "${Dismount}" 
                            } else /if (${GroupBuff[${a}].Left[8].Equal["activate"]}) { 
                                /echo -[ Casting Buff : ${GroupBuff[${a}]} on ${BuffPlayerName}. ]- 
                                /call Cast "${GroupBuff[${a}].Right[-9]}" "activate" "${Dismount}" 
                            } else { 
                                /echo -[ Casting Buff : ${GroupBuff[${a}]} on ${BuffPlayerName}. ]- 
                                /call Cast "${GroupBuff[${a}]}" "gem${GroupBuffMemToSlot[${a}]}" "${Dismount}" 
                            } 
                            /if (${Macro.Return.Equal["CAST_TOOK2LONG"]}) { 
                                /echo -(( Cast took too long, aborting. ))- 
                                /varset Reason Cast Took Too Long 
                                /goto :ErrorBuff 
                            } 
                            /if ((${Macro.Return.Equal["CAST_CANNOTSEE"]})||(${Macro.Return.Equal["CAST_OUTOFRANGE"]})) { 
                                /echo -(( Out of range or cannot be seen, aborting. ))- 
                                /varset Reason Target Out of Range 
                                /goto :ErrorBuff 
                            } 
                        } else { 
                            /varset Reason Unknown Error 
                            /goto :ErrorBuff 
                        } 
                    } else { 
                        /varset Reason Target Not in Zone or too far away 
                        /goto :ErrorBuff 
                    } 
                /next a 
                /goto :BreakOutRebuff1 
            } else { 
                /goto :ErrorBuff 
            } 
        } 
        :ErrorBuff 
        /delay 15 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Couldn't buff ${BuffPlayerName} because ${Reason}. 
        /echo -(( Couldn't buff ${BuffPlayerName} Reason:${Reason}. ))- 
    } 
} 
:BreakOutRebuff1 
/return 

Sub Event_Buff(EvtText) 
/varset EvtText ${EvtText.Right[-6]} 
/varset SenderName nobody 
/call BuffFunction "${EvtText}" 
/return 

Sub GroupBuffFunction(CmdText) 
/declare a int local 
/declare b int local 
/declare c int local 
/declare TempIndex int local 
/declare TempIndex2 int local 
/if (${GroupBuffCount}>0) { 
    /if (${CmdText.Equal["groupbuff"]}) { 
        /if (${PauseGroupBuffs}==0) { 
            /varset PauseGroupBuffs 1 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm not going to group buff. 
            /echo -[ Group Buffs Paused. ]- 
        } else { 
            /varset PauseGroupBuffs 0 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm going to group buff. 
            /echo -[ Group Buffs Unpaused. ]- 
        } 
    } else /if (${CmdText.Right[-10].Equal["all"]}) { 
        /for a 1 to ${GroupBuffCount} 
            /for b 1 to 6 
                /if (${Spell[${GroupBuffID[${a}]}].TargetType.Find["Group"]}) { 
                    /varset GBL[${a},${b}] 99999 
                    /if (${b}==1) /varset GBL[${a},${b}] 0 
                } else { 
                    /varset GBL[${a},${b}] 0 
                } 
            /next b 
        /next a 
        /echo -[ Group Buffing with all buffs. ]- 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll totally buff everyone. 
    } else /if (${CmdText.Right[-10].Arg[2].Length}>0) { 
        /for a 1 to 8 
            /if (${CmdText.Arg[2].Equal["${Int[${a}]}"]}) { 
                /if ((${CmdText.Arg[2]}>0)&&(${CmdText.Arg[2]}<${Math.Calc[${GroupBuffCount}+1]})) { 
                    /for b 1 to 6 
                        /if (${Group.Member[${Math.Calc[${b}-1]}].Name.Equal[${CmdText.Arg[3]}]} || ${b.Equal[${CmdText.Arg[3]}]}) {
                            /varset TempIndex ${CmdText.Arg[2]} 
                            /if (!${Spell[${GroupBuffID[${TempIndex}]}].TargetType.Find["Group"]}>0) { 
                                /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll buff ${Group.Member[${Math.Calc[${b}-1]}].CleanName} with ${GroupBuff[${a}]}. 
                                /echo -[ Group Buffing ${Group.Member[${Math.Calc[${b}-1]}].CleanName} with ${GroupBuff[${a}]}. ]- 
                                /varset GBL[${TempIndex},${b}] 0 
                            } else { 
                                /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Sorry, thats a group buff. 
                                /echo -(( Buff requested is a group based buff, not a single target buff. ))- 
                            } 
                        } 
                    /next b 
                    /goto :BreakOutRebuff1 
                } 
            } else /if (${CmdText.Arg[2].Equal[all]}) { 

                /for b 1 to 6 
                    /if (${Group.Member[${Math.Calc[${b}-1]}].Name.Equal[${CmdText.Arg[3]}]} || ${b.Equal[${CmdText.Arg[3]}]}) { 
                        /varset TempIndex ${a} 
                        /if (!${Spell[${GroupBuffID[${TempIndex}]}].TargetType.Find["Group"]}>0) { 
                            /varset GBL[${TempIndex},${b}] 0 
                        } else { 
                            /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Sorry, thats a group buff. 
                            /echo -(( Buff requested is a group based buff, not a single target buff. ))- 
                        } 
                    } 
                /next b 
                /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll buff ${Group.Member[${Math.Calc[${b}-1]}].CleanName} with every buff. 
                /echo -[ Group Buffing ${Group.Member[${Math.Calc[${b}-1]}].CleanName} with every buff. ]- 
            } 
        /next a 
        /if (${a}>8) /goto :LookUpAlias 
        /goto :BreakOutRebuff1 

        :LookUpAlias 
        /varset TempIndex2 0 
        /for c 1 to 8 
            /if (${GroupBuffAliasName[${c}].Equal[${CmdText.Arg[2]}]}) /varset TempIndex2 ${c} 
        /next c 

        /if ((${TempIndex2}>0)&&(${TempIndex2}<${Math.Calc[${GroupBuffCount}+1]})) { 
            /for b 1 to 6 
                /if (${Group.Member[${Math.Calc[${b}-1]}].Name.Equal[${CmdText.Arg[3]}]} || ${b.Equal[${CmdText.Arg[3]}]}) { 
                    /varset TempIndex ${TempIndex2} 
                    /if (!${Spell[${GroupBuffID[${TempIndex}]}].TargetType.Find["Group"]}>0) { 
                        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll buff ${Group.Member[${Math.Calc[${b}-1]}].CleanName} with ${GroupBuff[${TempIndex}]}. 
                        /echo -[ Group Buffing ${Group.Member[${Math.Calc[${b}-1]}].CleanName} with ${GroupBuff[${TempIndex}]}. ]- 
                        /varset GBL[${TempIndex},${b}] 0 
                    } else { 
                        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Sorry, thats a group buff. 
                        /echo -(( Buff requested is a group based buff, not a single target buff. ))- 
                    } 
                } 
            /next b 
            /goto :BreakOutRebuff1 
        } 

        :BreakOutRebuff1 
    } else { 
        /for a 1 to 8 
            /if (${CmdText.Arg[2].Equal["${Int[${a}]}"]}) { 
                /if ((${CmdText.Arg[2]}>0)&&(${CmdText.Arg[2]}<${Math.Calc[${GroupBuffCount}+1]})) { 
                    /for b 1 to 6 
                        /varset TempIndex ${CmdText.Arg[2]} 
                        /if (${Spell[${GroupBuffID[${TempIndex}]}].TargetType.Find["Group"]}) { 
                            /varset GBL[${TempIndex},${b}] 99999 
                            /if (${b}==1) /varset GBL[${TempIndex},${b}] 0 
                        } else { 
                            /varset GBL[${TempIndex},${b}] 0 
                        } 
                    /next b 
                    /goto :BreakOutRebuff2 
                } 
            } 
        /next a 
        /if (${a}>8) /goto :LookUpAlias2 
        :BreakOutRebuff2 
        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll buff everyone with ${GroupBuff[${a}]}. 
        /echo -[ Group Buffing everyone with ${GroupBuff[${a}]}. ]- 
        /return 

        :LookUpAlias2 

        /varset TempIndex2 0 
        /for c 1 to 8 
            /if (${GroupBuffAliasName[${c}].Equal[${CmdText.Arg[2]}]}) /varset TempIndex2 ${c} 
        /next c 

        /if (${TempIndex2}==0) { 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I couldn't find that buff. 
            /echo -(( Group Buff: ${CmdText.Arg[2]} could not be found. ))- 
            /return 
        } 

        /if ((${TempIndex2}>0)&&(${TempIndex2}<${Math.Calc[${GroupBuffCount}+1]})) { 
            /for b 1 to 6 
                /varset TempIndex ${TempIndex2} 
                /if (${Spell[${GroupBuffID[${TempIndex}]}].TargetType.Find["Group"]}) { 
                    /varset GBL[${TempIndex},${b}] 99999 
                    /if (${b}==1) /varset GBL[${TempIndex},${b}] 0 
                } else { 
                    /varset GBL[${TempIndex},${b}] 0 
                } 
            /next b 
        } 

        /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll buff everyone with ${GroupBuff[${TempIndex}]}. 
        /echo -[ Group Buffing everyone with ${GroupBuff[${TempIndex}]}. ]- 


    } 
} 
/return 

Sub Event_GroupBuff(EvtText) 
/varset EvtText ${EvtText.Right[-6]} 
/varset SenderName nobody 
/call GroupBuffFunction "${EvtText}" 
/return 

Sub Event_Exclude(EvtText) 
/varset EvtText ${EvtText.Right[-14]} 
/if (${EvtText.Length}>0) { 
    /varset SenderName nobody 
    /call AddExclude "${EvtText}" 
} 
/return 

Sub Event_Include(EvtText) 
/varset EvtText ${EvtText.Right[-14]} 
/if (${EvtText.Length}>0) { 
    /varset SenderName nobody 
    /call DelExclude "${EvtText}" 
} 
/return 

Sub Event_Enraged(EvtText) 
/if (${PausePet}==0) { 
    /assist ${Me.Pet.CleanName} 
    /delay 6 
    /if (${Target.CleanName.Find[${EvtText.Mid[1,${Math.Calc[${EvtText.Find[ has become ENRAGED]}-1]}]}]}>0) { 
      /if ( ${Me.AltAbility[Pet Discipline]} && ${UsePetHold} ) /pet hold
        /pet back off 
        /delay 5 
        /pet back off 
        /varset PetCheckTimer 20s 
    } 
} 
/return 

Sub SitFunction 
/if (${NoSit}==0) { 
    /if (!${Me.Standing}) /stand 
    /varset NoSit 1 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'll just stay standing for now. 
    /echo -[ You will no longer sit during idle time. ]- 
} else { 
    /varset NoSit 0 
    /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} I'll sit when I'm not busy with things. 
    /echo -[ You will now sit during idle time. ]- 
} 
/return 


Sub Event_Sit 
/varset SenderName nobody 
/call SitFunction 
/return 


Sub LoadWatchList 
/declare TempVar int local 
/declare a int local 
/declare b string local 

/for a 1 to 10 
    /varset WatchList[${a}] Empty 
    /varset HoTList[${a},1] 0 
    /varset HoTList[${a},2] 0 
/next a 

/varset TempVar 1 
/varset WatchListCount 0 
:LoadWatch 
/varset b ${Ini[${IniFile},Watch,${Int[${TempVar}]},NOTFOUND]} 
/if ((${WatchListCount}>10)||(${b.Equal["NOTFOUND"]})) { 
    /return 
} 
/if (!${b.Equal[Empty]}) { 
    /varset WatchListCount ${Math.Calc[${WatchListCount}+1]} 
    /varset WatchList[${WatchListCount}] ${b} 
} 
/varset TempVar ${Math.Calc[${TempVar}+1]} 
/goto :LoadWatch 
/return 

Sub LoadMasterList 
/declare TempVar int local 
/declare TempList string local 
/varset TempVar 0 

:ClearMasters 
/varset TempList ${Ini[${IniFile},Masters,${Int[${TempVar}]},NOTFOUND]} 
/if (${TempList.Equal["NOTFOUND"]}) /goto :DoneClearMasters 
/varset MasterList[${Math.Calc[${TempVar}+1]}] Empty 
/varset TempVar ${Math.Calc[${TempVar}+1]} 
/goto :ClearMasters 

:DoneClearMasters 
/varset TempVar 0 
:LoadMasters 
/varset MasterList[${Math.Calc[${TempVar}+1]}] ${Ini[${IniFile},Masters,${Int[${TempVar}]},NOTFOUND]} 
/if (${MasterList[${Math.Calc[${TempVar}+1]}].Equal["NOTFOUND"]}) /return 
/varset TempVar ${Math.Calc[${TempVar}+1]} 
/goto :LoadMasters 
/return 

Sub AddExclude(ExcludeName) 
   /declare Category string local 
   /declare EachExclude int local 
   /declare Exclude string local 
   /declare BlankExclude int local 
   /varset BlankExclude 0 
   /varset Category Excludes 
   /varset EachExclude 0 
:NextExclude1 
   /varset Exclude ${Ini[${IniFile},${Category},exclude_${Int[${EachExclude}]},NOTFOUND]} 
   /if (${Exclude.Find["NOTFOUND"]}) { 
      /goto :IniParsed 
   } 
   /if (${Exclude.Find["NONE"]}) { 
      /varset BlankExclude ${EachExclude} 
   } 

   /if (${Exclude.Find["${ExcludeName}"]}) { 
      /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Yeah, I'm ignoring ${ExcludeName} already. 
      /echo -(( ${ExcludeName} already on Exclude List ))- 
      /return 
   } 
   /varset EachExclude ${Math.Calc[${EachExclude}+1]} 
   /goto :NextExclude1 
:IniParsed 
   /if (${BlankExclude}==0) { 
      /ini ${IniFile} "${Category}" exclude_${Int[${EachExclude}]} "${ExcludeName}" 
   } else { 
      /ini ${IniFile} "${Category}" exclude_${Int[${BlankExclude}]} "${ExcludeName}" 
   } 
   /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm going to ignore ${ExcludeName}. 
   /echo -[ Added ${ExcludeName} to the exclusions list. ]- 
   /alert add ${AlertList} NPC "${ExcludeName}" 
/return 

Sub LoadExcludes 
   /declare Category string local 
   /declare EachExclude int local 
   /declare Exclude string local 
   /varset Category Excludes 
   /alert clear ${AlertList} 
   /alert add ${AlertList} advbot.mac 
   /alert add ${AlertList} NPC "eye of " 
   /if (${Ini[${IniFile},${Category},-1,NOTFOUND].Equal["NOTFOUND"]}) { 
      /echo -(( No Exclude list exists. ))- 
      /return 
   } 
   /varset EachExclude 0 
:NextExclude2 
   /varset Exclude ${Ini[${IniFile},${Category},exclude_${Int[${EachExclude}]},NOTFOUND]} 
   /if (${Exclude.Equal["NOTFOUND"]}) { 
      /return 
   } 
   /if (${Exclude.Find["NONE"]}) { 
   } else { 
     /alert add ${AlertList} NPC "${Exclude}" 
   } 
   /varset EachExclude ${Math.Calc[${EachExclude}+1]} 
   /goto :NextExclude2 
/return 

Sub DelExclude(ExcludeName) 
   /declare Category string local 
   /declare EachExclude int local 
   /declare Exclude string local 
   /varset Category Excludes 
   /if (${Ini[${IniFile},${Category},-1,NOTFOUND].Equal["NOTFOUND"]}) { 
      /echo -(( No Exclude list exists. ))- 
      /return 
   } 
   /varset EachExclude 0 
:NextExclude3 
   /varset Exclude ${Ini[${IniFile},${Category},exclude_${Int[${EachExclude}]},NOTFOUND]} 
   /if (${Exclude.Find["NOTFOUND"]}) { 
      /call LoadExcludes 
      /return 
   } 
   /if (${Exclude.Find["${ExcludeName}"]}) { 
      /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm not going to ignore ${ExcludeName} any more. 
      /echo -[ Removed ${ExcludeName} from the exclusions list. ]-        
      /ini ${IniFile} "${Category}" exclude_${Int[${EachExclude}]} NONE 
   } 
   /varset EachExclude ${Math.Calc[${EachExclude}+1]} 
   /goto :NextExclude3 
/return 

Sub SetupADVars 
/declare VarNpcCount int outer 0 
/declare DebuffCount int outer 
/declare SelfBuffCount int outer 
/declare Radius int outer 
/declare ZoneName string outer 
/declare TrackNumber int outer 
/declare PauseAssist int outer 
/declare MobList[51] int outer 
/declare MDL[51,10] int outer 
/declare SelfBuff[8] string outer UNDEFINED-ARRAY-ELEMENT 
/declare SelfBuffAliasName[8] string outer 
/declare SelfBuffID[8] int outer 0 
/declare SelfBuffDuration[8] int outer 
/declare SelfBuffedList[8] int outer 
/declare SelfBuffAtStart[8] int outer 
/declare SelfBuffIconCheck[8] int outer 
/declare SelfBuffIconName[8] string outer UNDEFINED-ARRAY-ELEMENT 
/declare SelfBuffMemToSlot[8] int outer 
/declare SelfBuffTimer timer outer 0 
/declare SelfBuffCheckTime string outer 
/declare Debuff[8] string outer UNDEFINED-ARRAY-ELEMENT 
/declare DebuffID[8] int outer 0 
/declare DebuffDuration[8] int outer 
/declare DebuffStartWait[8] int outer 
/declare DebuffMinHealth[8] int outer 
/declare DebuffMinMana[8] int outer 
/declare DebuffMinHealthNoCast[8] int outer 
/declare DebuffMinMobsInArea[8] int outer 
/declare DebuffMemToSlot[8] int outer 
/declare DebuffOnMATarget[8] int outer 
/declare DebuffTimer timer outer 0 
/declare DebuffCheckTime string outer 
/declare EventCount int outer 
/declare EventMinMana[8] int outer 
/declare EventMaxMana[8] int outer 
/declare EventMinHP[8] int outer 
/declare EventMaxHP[8] int outer 
/declare EventList[8] int outer 
/declare EventDuration[8] int outer 
/declare EventSpell[8] string outer UNDEFINED-ARRAY-ELEMENT 
/declare EventSpellID[8] int outer 0 
/declare EventMemToSlot[8] int outer 
/declare EventTimer timer outer 0 
/declare EventCheckTime string outer 
/declare MasterList[100] string outer UNDEFINED-ARRAY-ELEMENT 
/declare RetryCount int outer 
/declare IniFile string outer 
/declare PauseDebuffs int outer 
/declare NoSit int outer 
/declare PauseEvents int outer 
/declare HealCount int outer 
/declare HealSpell[8] string outer UNDEFINED-ARRAY-ELEMENT 
/declare HealSpellID[8] int outer 0 
/declare HealMinHP[8] int outer 
/declare HealMaxHP[8] int outer 
/declare HealMinMana[8] int outer 
/declare HealMinGroupCount[8] int outer 
/declare HealClass[8] string outer UNDEFINED-ARRAY-ELEMENT 
/declare HealAnnounce[8] string outer 
/declare HealMemToSlot[8] int outer 
/declare HealTimer timer outer 0 
/declare HealCheckTime string outer 
/declare HealPets int outer 0 
/declare WussyFactor int outer 10 
/declare PauseHeals int outer 
/declare HoTList[20,2] int outer 0 
/declare MobAnnounced[51,10] int outer 
/declare DebuffAnnounce[8] string outer 
/declare Announce int outer 
/declare AnnounceChannel string outer 
/declare GroupBuffCount int outer 
/declare GroupBuff[8] string outer UNDEFINED-ARRAY-ELEMENT 
/declare GroupBuffAliasName[8] string outer 
/declare GroupBuffID[8] int outer 0 
/declare GroupBuffDuration[8] int outer 
/declare GroupBuffAtStart[8] int outer 
/declare GroupBuffMinMana[8] int outer 
/declare GroupBuffMinGroupCount[8] int outer 
/declare GroupBuffMemToSlot[8] int outer 
/declare GroupBuffTimer timer outer 0 
/declare GroupBuffCheckTime string outer 
/declare GBL[9,20] int outer 
/declare GroupBuffAnnounce[8] string outer 
/declare GroupBuffClass[8] string outer UNDEFINED-ARRAY-ELEMENT 
/declare WatchList[11] string outer UNDEFINED-ARRAY-ELEMENT 
/declare WatchListCount int outer 0 
/declare WatchTimer[20] int outer 
/declare GroupCount int outer 
/varset GroupCount 0 
/declare AlertList int outer  
/varset AlertList 20 
/declare PauseSelfBuffs int outer 
/declare PauseGroupBuffs int outer 
/declare PausePet int outer 
/declare PetAssistOnHPPct int outer 98 
/declare UsePetHold int outer 1
/declare TankName string outer Main Assist Name 
/declare PetCheckTimer timer outer 0 
/declare PetBuffCheckTimer timer outer 0 
/declare PetCheckTime string outer 
/declare PetBuffCheckTime string outer 
/declare PetBuff[8] string outer 
/declare PetBuffIconName[8] string outer 
/declare PetBuffCount int outer 
/declare PetBuffMemToSlot[8] int outer 
/declare PetSummonSpell string outer 
/declare PetSummonMemToSlot int outer 
/declare FaceBeforeDebuff int outer 0
/declare MiscCheckTimer timer outer 0 
/declare SenderName string outer nobody 
/declare Reply int outer 
/declare ReplyChannel string outer 
/declare Dismount string outer nodismount 
/declare BotFollowDistance int outer 10 
/declare SitCheckTimer timer outer 0 
/declare SitAggroRadiusCheck int outer 75 
/declare DoAFK int outer
/declare AFKMessage string outer AFK Message
/return 

Sub Startup 
/declare a int local 
/declare b int local 
/declare c int local 
/call LoadINIVals 
/call LoadExcludes 
/call DistanceFunction ${BotFollowDistance} 
/for a 1 to ${TrackNumber} 
    /varset MobList[${a}] 0 
    /for b 1 to ${DebuffCount} 
        /varset MDL[${a},${b}] 0 
        /varset MobAnnounced[${a},${b}] 0 
    /next b 
/next a 
/for a 1 to ${SelfBuffCount} 
    /if (${SelfBuffAtStart[${a}]}==1) { 
        /varset SelfBuffedList[${a}] 0 
    } else { 
        /if (${SelfBuffedList[${a}]}==12345) { 
            /if (${Me.Buff["${SelfBuffIconName[${a}]}"].Name.Length}>0) { 
                /varset SelfBuffedList[${a}] ${Me.Buff["${SelfBuffIconName[${a}]}"].Duration.TotalSeconds} 
            } else { 
                /varset SelfBuffedList[${a}] 0 
            } 
        } else { 
            /varset SelfBuffedList[${a}] 99999 
        } 
    } 
/next a 
/for a 1 to ${GroupBuffCount} 
    /for b 0 to 5 
        /if (${GroupBuffAtStart[${a}]}==1) { 
            /varset GBL[${a},${Math.Calc[${b}+1]}] 0 
        } else { 
            /varset GBL[${a},${Math.Calc[${b}+1]}] 99999 
        } 
    /next b 
/next a 
/for a 1 to ${EventCount} 
    /varset EventList[${a}] 0 
/next a 
/for a 1 to 16 
    /varset HoTList[${a},1] 0 
    /varset HoTList[${a},2] 0 
    /varset WatchTimer[${a}] 0 
/next a 
/for a 1 to 10 
    /varset WatchList[${a}] Empty 
/next a 
/varset ZoneName ${Zone.Name} 
/if (${PauseDebuffs}==1) { 
    /echo -[ Debuffing Paused. ]- 
} 
/if (${FaceBeforeDebuff}==1) { 
    /echo -[ Facing before debuffs turned ON. ]- 
} 
/if (${PauseEvents}==1) { 
    /echo -[ HP and Mana Events Paused. ]- 
} 
/if (${PauseHeals}==1) { 
    /echo -[ Healing Paused. ]- 
} 
/if (${Announce}==0) { 
    /echo -[ Announcements OFF. ]- 
} 
/if (${PauseSelfBuffs}==1) { 
    /echo -[ Self Buffs Paused. ]- 
} 
/if (${PauseGroupBuffs}==1) { 
    /echo -[ Group Buffs Paused. ]- 
} 
/if (${PausePet}==0) { 
    /echo -[ Pet assisting un-paused. ]- 
} 
/if (${PauseAssist}==0) { 
    /echo -[ Assisting un-paused${If[!${TankName.Equal[Main Assist Name]}, you will be assisting ${TankName},]}. ]- 
} 
/call LoadMasterList 
/call MasterFunction "master" 
/call LoadWatchList 
/call WatchFunction "watch" 
/doevents flush 
/return 


Sub Event_DelayOnZone 
/varset HealTimer 8s 
/if (${PauseDebuffs}==0) /call DebuffFunction
/if (${PauseGroupBuffs}==0) /call GroupBuffFunction "groupbuff"
/if (${FollowFlag}==1) /call StopFunction
/keypress forward
/keypress back 
/call AFK
/return 

Sub Event_chat(MsgType,MsgFrom,MsgText) 
/declare TempVar int local 
/varset TempVar 0 
:CheckAuth 
/if (!${MasterList[${TempVar}].Equal["UNDEFINED-ARRAY-ELEMENT"]}) { 
    /if (${MasterList[${TempVar}].Equal["${MsgFrom}"]}) { 
        /varset SenderName ${MsgFrom} 
        /if (${MsgText.Equal["debuff"]}) { 
            /call DebuffFunction 
            /return 
        } 
        /if (${MsgText.Left[6].Equal["master"]}) { 
            /call MasterFunction "${MsgText}" 
            /return 
        } 
        /if (${MsgText.Left[8].Equal["selfbuff"]}) { 
            /call SelfBuffFunction "${MsgText}" 
            /return 
        } 
        /if (${MsgText.Left[9].Equal["groupbuff"]}) { 
            /call GroupBuffFunction "${MsgText}" 
            /return 
        } 
        /if (${MsgText.Left[4].Equal["buff"]}) { 
            /call BuffFunction "${MsgText}" 
            /return 
        } 
        /if (${MsgText.Left[6].Equal["follow"]}) { 
            /if (!${Me.Standing}) /stand 
            /if ((${MsgText.Equal["follow me"]})||(${MsgText.Equal["follow"]})) { 
                /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm going to follow you. 
                /call FollowFunction "${MsgFrom}" 
            } else { 
                /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm going to follow ${MsgText.Right[-7]}. 
                /call FollowFunction "${MsgText.Right[-7]}" 
            } 
            /return 
        } 
        /if (${MsgText.Left[4].Equal["goto"]}) { 
            /if (!${Me.Standing}) /stand 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm going to head to ${MsgText.Arg[2]}, ${MsgText.Arg[3]}. 
            /call GotoFunction "${MsgText.Arg[2]}" "${MsgText.Arg[3]}" 
            /return 
        } 
        /if (${MsgText.Left[4].Equal["stop"]}) { 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]}) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'll just stop here. 
            /call StopFunction 
            /return 
        } 
        /if (${MsgText.Left[3].Equal["sit"]}) { 
            /call SitFunction 
            /return 
        } 
        /if (${MsgText.Left[6].Equal["events"]}) { 
            /call EvtsFunction 
            /return 
        } 
        /if (${MsgText.Left[4].Equal["heal"]}) { 
            /if (${MsgText.Right[-5].Length}>0) { 
                /call HealFunction "${MsgText.Right[-5]}" 
            } else { 
                /call HealFunction 
            } 
            /return 
        } 
        /if (${MsgText.Left[4].Equal["face"]}) { 
            /call FaceFunction 
            /return 
        }  
        /if (${MsgText.Left[3].Equal["pet"]}) { 
            /if (${MsgText.Right[-4].Length}>0) { 
                /call PetFunction "${MsgText.Right[-4]}" 
            } else { 
                /call PetFunction 
            } 
            /return 
        } 
        /if (${MsgText.Left[3].Equal["cmd"]}) { 
            /if (${MsgText.Right[-4].Length}>0) { 
                /call CmdFunction "${MsgText.Right[-4]}" 
            } 
            /return 
        }  
        /if (${MsgText.Left[6].Equal["assist"]}) { 
            /if (${MsgText.Arg[2].Length}>0) { 
                /call AssistFunction "${MsgText.Arg[2]}" 
            } else { 
                /call AssistFunction 
            } 
            /return 
        } 
        /if (${MsgText.Left[7].Equal["exclude"]}) { 
            /call AddExclude "${MsgText.Right[-8]}" 
            /return 
        } 
        /if (${MsgText.Left[7].Equal["include"]}) { 
            /call DelExclude "${MsgText.Right[-8]}" 
            /return 
        } 
        /if (${MsgText.Left[5].Equal["watch"]}) { 
            /call WatchFunction "${MsgText}" 
            /return 
        } 
        /if (${MsgText.Left[8].Equal["announce"]}) { 
            /call AnnounceFunction 
            /return 
        } 
        /if (${MsgText.Left[5].Equal["reply"]}) { 
            /call ReplyFunction 
            /return 
        } 
        /if (${MsgText.Left[8].Equal["distance"]}) { 
            /call DistanceFunction "${MsgText.Right[-9]}" 
            /return 
        }  
         /if (${MsgText.Left[5].Equal["pause"]}) { 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]} ${PauseFlag}==1) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm going to wait here. Let me know when you want me to proceed. 
            /if (${Reply}==1 && !${SenderName.Equal[nobody]} ${PauseFlag}==0) /docommand /${If[${ReplyChannel.Find[ @]}>0,${ReplyChannel.Mid[1,${Math.Calc[${ReplyChannel.Find[ @]}-1]}]} ${SenderName},${ReplyChannel}]} Ok, I'm coming. 
            /call PauseFunction 
            /return 
        } 
    } 
    /varset TempVar ${Math.Calc[${TempVar}+1]} 
    /goto :CheckAuth 
} 
/return 

Sub AFK
/if ( ${DoAFK} ) {
  /if ( ${AFKMessage.Length} && !${AFKMessage.Equal[AFK Message]} ) {
    /afk ${AFKMessage}
  } else {
    /afk
  }
}
/return
